#!/bin/bash
make -j2
if [ "$?" -ne 0 ]; then echo "Make failed"; exit 1; fi
sudo losetup /dev/loop1 ../k3d/fd.img
sudo mount /dev/loop1 ../k3d/fdDir
sudo cp kernel.bin ../k3d/fdDir
sudo umount ../k3d/fdDir
sudo losetup --detach /dev/loop1

qemu -fda ../k3d/fd.img -hda ../k3d/hd.img -boot a -s -serial tcp::4444,server,nowait -S &

#Wait for qemu to run
sleep 1

gdb kernel.bin --command=.gdbinit
